<template>
    <div>
        <h3>添加员工</h3>
        姓名：<input type="text" v-model="employee.name"><br>
        电话：<input type="text" v-model="employee.tel"><br>
        职位：<input type="text" v-model="employee.job"><br>
        生日：<input type="date" v-model="employee.birthday"><br>
        头像：<input type="file" @change="getFile($event)"><br>
        <input type="button" value="添加" @click="add">
    </div>
</template>

<script>
export default {
    data(){
        return{
            employee:{},
            param:{}
        }
    },
    methods:{
        getFile(event){
            this.param.name = event.target.files[0].name;
            this.param.face = event.target.files[0];
            event.preventDefault();
        },
        async add(){
            var fileName = await this.ajax.uploadSubmit("/project/upload/add",this.param);
            this.employee.faceImg = fileName;
            var info = await this.ajax.getSubmit("/project/employee/add",this.employee);
            if(info == "ok"){
                this.$emit("page",{pageNO:1});
                this.employee = {};
            }
        }
    }
}
</script>

<style>

</style>